package com.dbiservices.dbiworker.tests;

import java.io.File;
import java.net.MalformedURLException;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;

import com.dbiservices.dbiworker.model.plugin.PluginInfo;

public class LoadPluginTests {

	/**
	 * @param args
	 * @throws JAXBException 
	 * @throws IllegalAccessException 
	 * @throws InstantiationException 
	 * @throws ClassNotFoundException 
	 * @throws MalformedURLException 
	 */
	public static void main(String[] args) throws JAXBException, MalformedURLException, ClassNotFoundException, InstantiationException, IllegalAccessException {
		// Store plugin
		
		PluginInfo info = new PluginInfo();
		info.setEnabled(true);
		info.setPluginClass("com.dbiservices.dbiworker.plugin.SQLWorker");
		
		File file = new File("plugins/com.dbiservices.main/plugin2.xml");
		JAXBContext jaxbContext = JAXBContext.newInstance(PluginInfo.class);
		Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
 
		// output pretty printed
		jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
 
		jaxbMarshaller.marshal(info, file);
		jaxbMarshaller.marshal(info, System.out);
		
		// end store plugin
		
		// Load plugin
		//PluginLoader loader = new PluginLoader();
		//ArrayList<Plugin> plugins = loader.load(loader.loadPluginFolders("plugins"));

	}

}
